package com.zhy.crowd_funding.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;

@Configuration
public class DruidPoolConfig {
    @Value("${spring.datasource.driverClassName}")
     private String driverClassName;
    @Value("${spring.datasource.url}")
    private String url;
    @Value("${spring.datasource.username}")
    private String username;
    @Value("${spring.datasource.password}")
    private String password;



    @Bean
    public DataSource druidDataSource(){
       DruidDataSource druidDataSource = new DruidDataSource();
         druidDataSource.setDriverClassName(driverClassName);
         druidDataSource.setUsername(username);
         druidDataSource.setPassword(password);
         druidDataSource.setUrl(url);
         return  druidDataSource;
    }



}
